package com.laoyao.util;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

import org.junit.Test;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

public class WordUtil {
	@SuppressWarnings(value={"unchecked", "rawtypes"})  
	public static List<String> word(String text) throws IOException{
 
        StringReader sr=new StringReader(text);  
        IKSegmenter ik=new IKSegmenter(sr, true);  
        Lexeme lex=null; 
         
        List list = new ArrayList<String>();
        while((lex=ik.next())!=null){  
            System.out.print(lex.getLexemeText()+"，");  
            list.add(lex.getLexemeText());
        } 
        return list;
	}
	
	public static String replaceWord(String str,int start,int end){
		String x = "";
		for(int i=start;i<end+1;i++){
			x+="*";
		}
		str=str.substring(0, start)+x+str.substring(end+1);
		return str;
	}
	@Test
	public void test(){
		System.out.println("hah人你大爷人人,你大爷".substring(13));
	}
}
